﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Text;

namespace BioCyber_Infection
{
    class CreditsScreen
    {
        SpriteFont titleFont;
        GameWindow window;
        Rectangle backGameButtonSource;
        Texture2D backgroundImage;

        /// <summary>
        /// Construtor
        /// </summary>
        public CreditsScreen(GameWindow gameWindow, ContentManager content)
        {
            this.window = gameWindow;

            this.backgroundImage = content.Load<Texture2D>("background");

            this.titleFont = content.Load<SpriteFont>("SpriteFont1");

            backGameButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 250, 50, 25);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(backgroundImage, new Rectangle(0, 0, window.ClientBounds.Width, window.ClientBounds.Height), Color.White);
                        
            string message = string.Empty;

            message = "Programadores:\n" + "\n" +
                      "Allan ALegretti\n" +
                      "Felipe Paixao 1\n" +
                      "Felipe Paixao 2\n" +
                      //"Renan Barbosa\n" +
                      "Ryan Coutinho\n" +
                      "Vitor Dellamora";

            spriteBatch.DrawString(titleFont, message, new Vector2((int)(window.ClientBounds.Width * 0.05), 50), Color.White);

            spriteBatch.DrawString(titleFont, "Back", new Vector2((float)(backGameButtonSource.X), (float)(backGameButtonSource.Y)), Color.White);
        }

        public void Update(GameTime gameTime)
        {
            if (Mouse.GetState().LeftButton == ButtonState.Pressed && Engine.currentState == Engine.gameState.CREDITS)
            {
                if (Engine.isColliding(backGameButtonSource, Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.MAINMENU;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Escape) && Engine.currentState == Engine.gameState.CREDITS)
            {
                Engine.currentState = Engine.gameState.MAINMENU;
            }
        }
    }
}
